package com.chixing.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

@Controller
public class SessionController {

    @GetMapping("/sessiondemo")
    @ResponseBody
    public String getSession(HttpSession session){
        System.out.println("session id:"  + session.getId());
        session.setAttribute("custName","smith");
        String value = (String)session.getAttribute("custName");
        System.out.println("session 中的数据value:"+ value) ;


        int time = session.getMaxInactiveInterval();
        System.out.println("MaxInactiveInterval:" + time);
        // session.invalidate();// 使得当前session失效，生命周期结束
        return "success";
    }
}
